/* Fenil Chandarana Fab Academy 2022 Webpage link: https://fabacademy.org/2022/labs/vigyanashram/students/fenil-chandarana/ */ int buttonState = 0; // variable for reading the pushbutton status void setup() { // initialize the LED pin as an output: pinMode(2, OUTPUT); // initialize the pushbutton pin as an input: pinMode(3, INPUT); } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(3); // check if the pushbutton is pressed. If it is, the buttonState is HIGH: if (buttonState == HIGH) { // turn LED on: digitalWrite(2, HIGH); } else { // turn LED off: digitalWrite(2, LOW); } }